using Microsoft.Xna.Framework;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;

namespace INdT.Sparta.Physics
{
    public class SpartaPhysics
    {
        public static float MeterPerPixel;

        public static World world;

        public static Vector2 ConvertUnits(Vector2 unit)
        {
            return unit * MeterPerPixel;
        }

        public static Body AddBox2DRectangle(int width, int height, float density)
        {
            Body body;

            body = BodyFactory.CreateRectangle(SpartaPhysics.world, width / MeterPerPixel, height / MeterPerPixel, density);
            body.Position = new Vector2(0f, 0f);
            body.BodyType = FarseerPhysics.Dynamics.BodyType.Dynamic;

            return body;
        }

        public static Body AddBox2DRectangle(int width, int height, float density, Vector2 position)
        {
            Body body;

            body = BodyFactory.CreateRectangle(SpartaPhysics.world, width / MeterPerPixel, height / MeterPerPixel, density);
            body.Position = new Vector2(0f, 0f);
            body.BodyType = FarseerPhysics.Dynamics.BodyType.Dynamic;
            body.Position = position;

            return body;
        }
    }
}
